<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		created: function() {
			uni.showLoading({
				title: '检查登录状态.....',
				mask: false
			})
			let user = uni.getStorageSync(this.$params.user)

			if (!user) {
				return
			}
			let username = uni.getStorageSync(this.$params.userName)
			let password = this.$aesUtil.decrypt(uni.getStorageSync(this.$params.EncryptPwd))
			let url = this.$params.host + 'api/v1/login'
			if (user) {
				this.$request.post(url, {
					"username": username,
					"password": password
				}, res => {
					uni.setStorageSync(this.$params.user, res.data)
					uni.setStorageSync(this.$params.userName, username)
					uni.setStorageSync(this.$params.EncryptPwd, this.$aesUtil.encrypt(password))
					this.$notification.postNotification(this.$params.noti_refresh_user, res.data)
				}, () => {}, () => {
					uni.hideLoading();
				})
			} else {
				uni.hideLoading();
			}
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	@import url("/common/icon.css");
	@import url("common/font-library.css");

	page {
		background-color: #fcfcfc;
	}
</style>